<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>分类管理</title>
    <style type="text/css">
        .plus_minus{
            width: 20px;
        }
    </style>
    <script src="__STATIC__/Js/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="__STATIC__/hdjs/hdjs.css"/>
    <script src="__STATIC__/hdjs/hdjs.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="__STATIC__/bootstrap/css/bootstrap.min.css"/>
    
    <script type="text/javascript">
    	$(function(){
    		//所有子集分类隐藏
    		$('tr[pid!=0]').hide();
    		//点击展开和收缩
    		$('.click-btn').toggle(function(){
    			//获得cid
    			var cid = $(this).parents('tr').attr('cid');
    			//子分类显示
    			$('tr[pid='+cid+']').show();
    			//删除+变成-
    			$(this).removeClass('glyphicon-plus').addClass('glyphicon-minus');
    		},function(){
    			//获得cid
    			var cid = $(this).parents('tr').attr('cid');
    			//异步
    			$.ajax({
    				type:"post",
    				url:"{|U:'Admin/Category/getSon'}",
    				data:{cid : cid},
    				dataType:'json',
    				success:function(phpData){
    					$.each(phpData, function(k,v) {    
    						//让所有子集分类的tr隐藏
    						$('tr[cid='+v+']').hide();                                                        
    					});
    				}
    			});
    			
    			
    			//删除-变成+
    			$(this).removeClass('glyphicon-minus').addClass('glyphicon-plus');
    		})
    		
    	})
    </script>
</head>
<body>
<div class="wrap">
    <table class="hd-table hd-table-form hd-form">
        <thead>
        <tr pid=0>
            <td width="30"></td>
            <td>分类ID</td>
            <td>分类名称</td>
            <td>分类排序</td>
            <td width="200">操作</td>
        </tr>
        </thead>
        <tbody>
        	<foreach from="$data" key="$k" value="$v">
	        	<tr pid="{$v.pid}" cid="{$v.cid}">
		            <td width="30">
		            	<a href="javascript:;" class="glyphicon glyphicon-plus click-btn"></a>
		            </td>
		            <td>{$v.cid}</td>
		            <td>{$v._name}</td>
		            <td>{$v.sort}</td>
		            <td width="200">
		            	<a href="{|U:'Admin/Category/addSon',array('cid'=>$v['cid'])}" class="hd-btn hd-btn-success hd-btn-xm">添加子分类</a>
						<a href="{|U:'Admin/Category/edit',array('cid'=>$v['cid'])}" class="hd-btn hd-btn-primary hd-btn-xm">编辑</a>
						<a href="{|U:'Admin/Category/del',array('cid'=>$v['cid'])}" class="hd-btn hd-btn-danger hd-btn-xm">删除</a>
		            </td>
		        </tr>
        	</foreach>
        	
        </tbody>
    </table>
    
    <div class="page_hdjob">
        
    </div>
</div>

</body>
</html>


